<?php
namespace app\index\controller;
use think\Controller;

class Video extends Controller
{
    public function index()
    {
    	// 推荐视频
    	$nvideo = db('video')->where(['type'=>1,'status'=>1])->field('id,title,url,addtime')->select();
    	foreach ($nvideo as &$val) {
    		$val['addtime'] = date('y-m-d h:i',$val['addtime']);
    	}
    	// 普通视频
    	$video = db('video')->where(['type'=>0,'status'=>1])->field('id,title,url,addtime')->select();
    	foreach ($video as &$val) {
    		$val['addtime'] = date('y-m-d h:i',$val['addtime']);
    	}
    	// 所有视频num
    	$num = db('video')->count('*');
    	// 所有版主查询
        $banzhu = db('information')->field('userid,name')->where('type',2)->select();
    	// var_dump($video);die;
        $this->assign("title",'视频站');
        $this->assign("nvideo",$nvideo);
        $this->assign("video",$video);
        $this->assign("num",$num);
        $this->assign("banzhu",$banzhu);
        return $this->fetch();
    }
    // 视频详情
    public function video($id)
    {
        $video = db('video')->where('id',$id)->find();
        // var_dump($video);die;
        $this->assign("video",$video);
        
        return $this->fetch();
    }
}
